home *** CD-ROM | disk | FTP | other *** search
/ Floppyshop 2 / Floppyshop - 2.zip / Floppyshop - 2.iso / art&graf.ix / art-3718 / extendpi / read_me.s < prev   
Text File  |  1993-03-02  |  8KB  |  340 lines

  1. ********************************************************************************
  2. * Have you ever tried to load a PI1 format picture into Deluxe Paint
  3. * and got this error message:
  4. *     'Unable to open file. The
  5. *      file is non-existent or
  6. *      a drive error occurred.'
  7. * even though the picture is there on the screen?  It is possible
  8. * that the palette is incorrect and the last screen line may be
  9. * corrupted.
  10. * If you have this problem, check the length of the file.  Deluxe
  11. * Paint expects a PI1 file to be 32066 bytes long, although many
  12. * other packages can handle PI1s 32034 bytes long.  PicSwitch 0.7
  13. * seems to be fond of this size.
  14. * If your file is 32034 bytes long, this program should solve your
  15. * problem.  If not, then you have my commiserations.  If the file
  16. * is 32034 bytes long and this program doesn't fix things, and the
  17. * problem isn't a disk fault, you could always drop me a line with
  18. * a copy of the file - I'd be interested to see it and I might be
  19. * able to fix it.  (I can't guarantee it though.)
  20. * The missing 32 bytes actually contain information used in colour
  21. * cycling, so are normally zeroes anyway.  This program scans your
  22. * disk for PI1s, PI2s, and PI3s 32034 bytes long, loads them into
  23. * memory, creates a blank colour cycling table and rewrites them
  24. * to disk.  (NB This doesn't require extra disk space as files
  25. * 32034 and 32066 bytes long both use 32 clusters.)
  26. * This program and source code/documentation are completely free
  27. * and are distributed with no strings attached.  However, I do
  28. * assert my right to be identified as the author of this software
  29. * in accordance with the Copyright, Designs and Patents Act 1988.
  30. * If you find this program useful, please let me know.  I don't
  31. * believe in moral blackmail so I won't ask you for anything, but
  32. * a couple of quid, a blank disk or two, picture files, PD or just
  33. * a letter would be equally acceptable, as would recommendations 
  34. * for improvements and future developments.  Whatever you send,
  35. * you're likely to get back:
  36. *
  37. *     A self-extracting archive creator
  38. *
  39. *     Details on how to get 70+ PI1 pictures on a disk, and not
  40. *     have to mess about with an unpacker to display them or work
  41. *    on them.
  42. *
  43. *     Anything interesting that I write between now (2/93) and
  44. *     then.
  45. * Much as I would like to, I cannot accept any responsibility for
  46. * loss or damage, material or notional, caused by the use or misuse
  47. * of this program.  As far as I know, it works as described, but if
  48. * it doesn't, let me know.
  49. * Deluxe Paint is copyright by Artistech Developments 1990 and is
  50. * distributed in the UK by Electronic Arts.
  51. * Write to:
  52. *     Dave Jones,
  53. *     100, Radford Road,
  54. *     Hyson Green,
  55. *     Nottingham,
  56. *     NG7 5FU,
  57. *     ENGLAND
  58. ********************************************************************************
  59. *
  60. * Assembler control directives
  61. *
  62.         output    extendpi.tos
  63.         opt    o1+,o2+,ow-
  64. *
  65. ********************************************************************************
  66. *
  67. * Constants for trap instruction
  68. *
  69. GEMDOS        equ    $01
  70. XBIOS        equ    $0e
  71. *
  72. ********************************************************************************
  73. *
  74. * Constants for GEMDOS functions
  75. *
  76. CRAWCIN        equ    $07
  77. CCONWS        equ    $09
  78. FSETDTA        equ    $1a
  79. FCREATE        equ    $3c
  80. FOPEN        equ    $3d
  81. FCLOSE        equ    $3e
  82. FREAD        equ    $3f
  83. FWRITE        equ    $40
  84. PTERM        equ    $4c
  85. FSFIRST        equ    $4e
  86. FSNEXT        equ    $4f
  87. *
  88. ********************************************************************************
  89. *
  90. * Constants for XBIOS functions
  91. *
  92. CURSCONF    equ    $15
  93. *
  94. ********************************************************************************
  95. *
  96. * Constants for XBIOS $15 - CursConf
  97. *
  98. CURS_OFF    equ    $00
  99. CURS_ON        equ    $01
  100. *
  101. ********************************************************************************
  102. *
  103. * The file sizes involved.  We want to convert short-sized PI?s to
  104. * long-sized ones.
  105. *
  106. SHORT_SIZE    equ    32034
  107. LONG_SIZE    equ    32066
  108. *
  109. *
  110. ********************************************************************************
  111. *
  112. * Macros for frequent functions
  113. *
  114. pstring        MACRO
  115.         pea    \1
  116.         move.w    #CCONWS,-(a7)
  117.         trap    #GEMDOS
  118.         addq.l    #6,a7
  119.         ENDM
  120. *
  121. cursor        MACRO
  122.         move.w    #CURSCONF,-(a7)
  123.         trap    #XBIOS
  124.         addq.l    #4,a7
  125.         ENDM
  126. *
  127. getkey        MACRO
  128.         move.w    #CRAWCIN,-(a7)
  129.         trap    #GEMDOS
  130.         addq.l    #2,a7
  131.         ENDM
  132. *
  133. ********************************************************************************
  134. *
  135. * Code starts here
  136. *
  137. ********************************************************************************
  138.  
  139. start        * no error yet
  140.         clr.w    return_code
  141.  
  142.         * hide cursor
  143.         move.w    #CURS_OFF,-(a7)
  144.         cursor
  145.  
  146.         * say hello
  147.         pstring    banner
  148.         getkey
  149.  
  150.         cmp.b    #' ',d0        space continues
  151.         bne    exit        anything else exits
  152.  
  153.         * set dta
  154.         pea    dta        our buffer
  155.         move.w    #FSETDTA,-(a7)
  156.         trap    #GEMDOS
  157.         addq.l    #6,a7
  158.  
  159.         * find first
  160.         clr.w    -(a7)        normal file r/w
  161.         pea    file_spec    *.PI?
  162.         move.w    #FSFIRST,-(a7)
  163.         trap    #GEMDOS
  164.         addq.l    #8,a7
  165.  
  166.         tst.l    d0        -ve = no files
  167.         bmi    no_files
  168.  
  169. loop        * check size
  170.         cmpi.l    #SHORT_SIZE,size
  171.         bne    skip
  172.  
  173.         * display file name
  174.         pstring    process
  175.         pstring    name
  176.  
  177.         * read file
  178.         clr.w    -(a7)
  179.         pea    name
  180.         move.w    #FOPEN,-(a7)
  181.         trap    #GEMDOS
  182.         addq.l    #8,a7
  183.  
  184.         tst.l    d0
  185.         bmi    error
  186.  
  187.         move.w    d0,-(a7)    put handle on stack for later
  188.  
  189.         pea    buffer
  190.         pea    SHORT_SIZE
  191.         move.w    d0,-(a7)
  192.         move.w    #FREAD,-(a7)
  193.         trap    #GEMDOS
  194.         lea    12(a7),a7
  195.  
  196.         tst.l    d0
  197.         bmi    error
  198.  
  199.         move.w    #FCLOSE,-(a7)    handle's there already
  200.         trap    #GEMDOS
  201.         addq.l    #4,a7
  202.  
  203.         tst.l    d0
  204.         bmi    error
  205.  
  206.         * clear end
  207.         lea    buffer+SHORT_SIZE,a0
  208.         moveq    #LONG_SIZE-SHORT_SIZE-1,d0
  209. clear        clr.b    (a0)+
  210.         dbf    d0,clear
  211.  
  212.         * write file
  213.         clr.w    -(a7)
  214.         pea    name
  215.         move.w    #FCREATE,-(a7)
  216.         trap    #GEMDOS
  217.         addq.l    #8,a7
  218.  
  219.         tst.l    d0
  220.         bmi    error
  221.  
  222.         move.w    d0,-(a7)    put handle on stack for later
  223.  
  224.         pea    buffer
  225.         pea    LONG_SIZE
  226.         move.w    d0,-(a7)
  227.         move.w    #FWRITE,-(a7)
  228.         trap    #GEMDOS
  229.         lea    12(a7),a7
  230.  
  231.         tst.l    d0
  232.         bmi.s    error
  233.  
  234.         move.w    #FCLOSE,-(a7)    handle's there already
  235.         trap    #GEMDOS
  236.         addq.l    #4,a7
  237.  
  238.         tst.l    d0
  239.         bmi.s    error
  240.  
  241.         pstring    done
  242.  
  243. skip        * find next
  244.         move.w    #FSNEXT,-(a7)
  245.         trap    #GEMDOS
  246.         addq.l    #2,a7
  247.  
  248.         tst.l    d0
  249.         bmi.s    no_more_files
  250.  
  251.         bra    loop
  252.  
  253. no_files    pstring    empty
  254.         bra.s    exit
  255.  
  256. no_more_files    pstring    more            fall through to exit
  257.  
  258. exit        pstring    end_message
  259.         getkey
  260.  
  261.         * show cursor
  262.         move.w    #CURS_ON,-(a7)
  263.         cursor
  264.  
  265.         move.w    return_code,-(a7)    error code (if any)
  266.         move.w    #PTERM,-(a7)
  267.         trap    #GEMDOS
  268.  
  269. error        move.w    d0,return_code
  270.         pstring    error_msg
  271.         bra.s    exit
  272.  
  273.  
  274. file_spec    dc.b    "*.pi?",0
  275.  
  276. banner        dc.b    $1b,"E"
  277.         dc.b    "Extend PI1-3 files - ZZD '93"
  278.         dc.b    $0d,$0a
  279.         dc.b    "~~~~~~~~~~~~~~~~~~~~~~~~~~~~"
  280.         dc.b    $0d,$0a
  281.         dc.b    $0d,$0a
  282.         dc.b    "Space to continue, any other key to exit"
  283.         dc.b    $0d,$0a
  284.         dc.b    $0d,$0a
  285.         dc.b    0
  286.  
  287. empty        dc.b    "There are no PI? files in this directory"
  288.         dc.b    $0d,$0a
  289.         dc.b    0
  290.  
  291. more        dc.b    $0d,$0a
  292.         dc.b    "All files processed"
  293.         dc.b    $0d,$0a
  294.         dc.b    0
  295.  
  296. process        dc.b    "Processing "
  297.         dc.b    0
  298.  
  299. done        dc.b    " - done"
  300.         dc.b    $0d,$0a
  301.         dc.b    0
  302.  
  303.  
  304. end_message    dc.b    $0d,$0a
  305.         dc.b    "Press any key to exit"
  306.         dc.b    $0d,$0a
  307.         dc.b    0
  308.  
  309. error_msg    dc.b    $0d,$0a
  310.         dc.b    "A fatal error has occurred"
  311.         dc.b    $0d,$0a
  312.         dc.b    0
  313.  
  314.         even
  315.         bss
  316.  
  317. dta
  318. reserved    ds.b    21        reserved for GEM
  319. attribute    ds.b    1
  320. time        ds.b    2        time and
  321. date        ds.b    2        date of file creation
  322. size        ds.b    4        file length (long)
  323. name        ds.b    14        file name
  324.  
  325. return_code    ds.w    1
  326. buffer        ds.w    16033
  327.